Electron 28.0.0 正式发布
Electron 28.0.0 版本已正式发布🎉,带来不少特性更新🌟,大家可以通过 npm i electron@latest
快速安装使用。亮点包括:
增加对 ESM 的支持 Electron Forage 添加了对 ESM 支持 Chromium 更新至 120.0.6099.56 V8 引擎升级 其他错误修复和改进
重要更改
Electron 28.0.0 版本实现了对 ECMAScript模块 或 ESM 的支持。这包括对 Electron 本身以及 UtilityProcess
API 等的 ESM 支持。同时,Electron 团队还为 Electron Forge 添加了 ESM 支持!支持使用ESM来打包、构建和开发Electron应用程序,您可以在 Electron Forge 7.0.0 及更高版本中使用 ESM。
依赖升级
Chromium 120.0.6099.56,可以使用 Chrome 119-120 以及 Chrome DevTools 中的新增功能,具体可以参考 Chrome 119 DevTools 新特性一览,Chrome 120 DevTools 新功能速览 Node.js 升级到 18.18.2 版本 V8 引擎升级到 12.0
特性更新
启用 ESM 支持。 向 UtilityProcess
API 添加了 ESM 入口点。向 display
对象添加了几个属性,包括detected
、maximumCursorSize
和nativeOrigin
。在 Linux 上添加了对 ELECTRON_OZONE_PLATFORM_HINT
环境变量的支持。
重大变化
WebContents.backgroundThrottling 变化
将 WebContents.backgroundThrottling
设置为 false 将禁用 BrowserWindow 中所有 WebContents 的帧节流。
移除 BrowserWindow.setTrafficLightPosition()
已移除 BrowserWindow.setTrafficLightPosition(position)
,应改用 BrowserWindow.setWindowButtonPosition(position)
API,它接受 null 而不是 { x: 0, y: 0 } 来重置位置为系统默认值。
// 在 Electron 28 被移除
win.setTrafficLightPosition({ x: 10, y: 10 });
win.setTrafficLightPosition({ x: 0, y: 0 });
// 替换为
win.setWindowButtonPosition({ x: 10, y: 10 });
win.setWindowButtonPosition(null);
移除 BrowserWindow.getTrafficLightPosition()
已移除 BrowserWindow.getTrafficLightPosition()
,应改用 BrowserWindow.getWindowButtonPosition()
API,在没有自定义位置时返回 null,而不是{ x: 0, y: 0 }。
// 在Electron 28中被移除
const pos = win.getTrafficLightPosition();
if (pos.x === 0 && pos.y === 0) {
// 没有自定义位置。
}
// 替换为
const ret = win.getWindowButtonPosition();
if (ret === null) {
// 没有自定义位置。
}
移除 ipcRenderer.sendTo()
已移除 ipcRenderer.sendTo()
API。应该通过在渲染器之间设置一个 MessageChannel
来替代它。
IpcRendererEvent
的 senderId
和 senderIsMainFrame
属性也已被删除。
移除:app.runningUnderRosettaTranslation
已移除 app.runningUnderRosettaTranslation
属性。请改用 app.runningUnderARM64Translation
。
// 在 Electron 28 中被移除
console.log(app.runningUnderRosettaTranslation);
// 替换为
console.log(app.runningUnderARM64Translation);
结束对 25.x.y 版本支持
根据该项目的支持政策,Electron 25.x.y 已经达到支持结束的状态。开发人员和应用程序被鼓励升级到新版本的 Electron。
E28 (Dec'23) | E29 (Feb'24) | E30 (Apr'24) |
---|---|---|
28.x.y | 29.x.y | 30.x.y |
27.x.y | 28.x.y | 29.x.y |
26.x.y | 27.x.y | 28.x.y |
未来计划
在短期内,Electron 团队会继续专注于 Electron 的主要组件(包括Chromium、Node 和 V8)的开发。Electron 经常在发布 Chromium 版本的同时发布重要版本,更多特性尽请期待。
附:主要版本时间线
Electron | Alpha | Beta | Stable | EOL | Chrome | Node | Supported |
---|---|---|---|---|---|---|---|
29.0.0 | 2023-Dec-07 | 2023-Jan-24 | 2023-Feb-20 | 2024-Aug-20 | M122 | v18.19 | ✅ |
28.0.0 | 2023-Oct-11 | 2023-Nov-06 | 2023-Dec-05 | 2024-Jun-11 | M120 | v18.18 | ✅ |
27.0.0 | 2023-Aug-17 | 2023-Sep-13 | 2023-Oct-10 | 2024-Apr-16 | M118 | v18.17 | ✅ |
26.0.0 | 2023-Jun-01 | 2023-Jun-27 | 2023-Aug-15 | 2024-Feb-20 | M116 | v18.16 | ✅ |
25.0.0 | 2023-Apr-10 | 2023-May-02 | 2023-May-30 | 2023-Dec-05 | M114 | v18.15 | 🚫 |
24.0.0 | 2023-Feb-09 | 2023-Mar-07 | 2023-Apr-04 | 2023-Oct-10 | M112 | v18.14 | 🚫 |
23.0.0 | 2022-Dec-01 | 2023-Jan-10 | 2023-Feb-07 | 2023-Aug-15 | M110 | v18.12 | 🚫 |
22.0.0 | 2022-Sep-29 | 2022-Oct-25 | 2022-Nov-29 | 2023-Oct-10 | M108 | v16.17 | 🚫 |
21.0.0 | 2022-Aug-04 | 2022-Aug-30 | 2022-Sep-27 | 2023-Apr-04 | M106 | v16.16 | 🚫 |
20.0.0 | 2022-May-26 | 2022-Jun-21 | 2022-Aug-02 | 2023-Feb-07 | M104 | v16.15 | 🚫 |
大家都在看